import 'dart:convert';
import 'package:ichinesereader/exam/dto/assessment.response.dart';

QuestionsResult questionsResultFromJson(String str) =>
    QuestionsResult.fromJson(json.decode(str));
String questionsResultToJson(QuestionsResult data) =>
    json.encode(data.toJson());
QuestionResult questionResultFromJson(String str) =>
    QuestionResult.fromJson(json.decode(str));
String questionResultToJson(QuestionResult data) => json.encode(data.toJson());
QuestionDto questionDtoFromJson(String str) =>
    QuestionDto.fromJson(json.decode(str));
String questionDtoToJson(QuestionDto data) => json.encode(data.toJson());
Question questionFromJson(String str) => Question.fromJson(json.decode(str));
String questionToJson(Question data) => json.encode(data.toJson());

class QuestionsResult {
  QuestionsResult({
    this.limit,
    this.page,
    this.count,
    this.list,
  });

  int? limit;
  int? page;
  int? count;
  List<Question>? list;

  factory QuestionsResult.fromJson(Map<String, dynamic> json) =>
      QuestionsResult(
        limit: json["limit"],
        page: json["page"],
        count: json["count"],
        list: json["list"] != null
            ? List<Question>.from(json["list"].map((x) => Question.fromJson(x)))
            : null,
      );

  Map<String, dynamic> toJson() => {
        "limit": limit,
        "page": page,
        "count": count,
        "list": list != null
            ? List<dynamic>.from(list!.map((x) => x.toJson()))
            : null,
      };
}

class QuestionResult {
  QuestionResult({
    this.status,
    this.message,
    this.result,
  });

  int? status;
  String? message;
  Result? result;

  factory QuestionResult.fromJson(Map<String, dynamic> json) => QuestionResult(
        status: json["status"],
        message: json["message"],
        result: json["result"] != null ? Result.fromJson(json["result"]) : null,
      );

  Map<String, dynamic> toJson() => {
        "status": status,
        "message": message,
        "result": result != null ? result?.toJson() : null,
      };
}

class Result {
  Result({
    this.question,
  });

  Question? question;

  factory Result.fromJson(Map<String, dynamic> json) => Result(
        question: json["question"] != null
            ? Question.fromJson(json["question"])
            : null,
      );

  Map<String, dynamic> toJson() => {
        "question": question != null ? question?.toJson() : null,
      };
}

class QuestionDto {
  QuestionDto({
    this.commitTime,
    this.content,
    this.id,
    this.kind,
    this.label,
    this.limitTime,
    this.majorLevel,
    this.minorLevel,
    this.questions,
    this.scope,
    this.topic,
    this.type,
  });

  int? commitTime;
  QuestionContent? content;
  String? id;
  String? kind;
  String? label;
  int? limitTime;
  int? majorLevel;
  int? minorLevel;
  List<QuestionItem>? questions;
  String? scope;
  String? topic;
  String? type;

  factory QuestionDto.fromJson(Map<String, dynamic> json) => QuestionDto(
        commitTime: json["commitTime"],
        content:
            json["content"] != null ? QuestionContent.fromJson(json["content"]) : null,
        id: json["id"],
        kind: json["kind"],
        label: json["label"],
        limitTime: json["limitTime"],
        majorLevel: json["majorLevel"],
        minorLevel: json["minorLevel"],
        questions: json["questions"] != null
            ? List<QuestionItem>.from(
                json["questions"].map((x) => QuestionItem.fromJson(x)))
            : null,
        scope: json["scope"],
        topic: json["topic"],
        type: json["type"],
      );

  Map<String, dynamic> toJson() => {
        "commitTime": commitTime,
        "content": content != null ? content?.toJson() : null,
        "id": id,
        "kind": kind,
        "label": label,
        "limitTime": limitTime,
        "majorLevel": majorLevel,
        "minorLevel": minorLevel,
        "questions": questions != null
            ? List<dynamic>.from(questions!.map((x) => x.toJson()))
            : null,
        "scope": scope,
        "topic": topic,
        "type": type,
      };
}

class Question {
  Question({
    this.commitTime,
    this.content,
    this.id,
    this.kind,
    this.label,
    this.limitTime,
    this.majorLevel,
    this.minorLevel,
    this.questions,
    this.scope,
    this.topic,
    this.type,
  });

  int? commitTime;
  QuestionContent? content;
  String? id;
  String? kind;
  String? label;
  int? limitTime;
  int? majorLevel;
  int? minorLevel;
  List<QuestionItem>? questions;
  String? scope;
  String? topic;
  String? type;

  factory Question.fromJson(Map<String, dynamic> json) => Question(
        commitTime: json["commitTime"],
        content:
            json["content"] != null ? QuestionContent.fromJson(json["content"]) : null,
        id: json["id"],
        kind: json["kind"],
        label: json["label"],
        limitTime: json["limitTime"],
        majorLevel: json["majorLevel"],
        minorLevel: json["minorLevel"],
        questions:json["questions"]!=null ? List<QuestionItem>.from(
            json["questions"].map((x) => QuestionItem.fromJson(x))): null,
        scope: json["scope"],
        topic: json["topic"],
        type: json["type"],
      );

  Map<String, dynamic> toJson() => {
        "commitTime": commitTime,
        "content": content != null ? content?.toJson() : null,
        "id": id,
        "kind": kind,
        "label": label,
        "limitTime": limitTime,
        "majorLevel": majorLevel,
        "minorLevel": minorLevel,
        "questions": questions != null
            ? List<dynamic>.from(questions!.map((x) => x.toJson()))
            : null,
        "scope": scope,
        "topic": topic,
        "type": type,
      };
}